#include <iostream>
#include <cstdlib>

template <class TYPE>
class BinaryTreeNode;

template <class TYPE>
class BinaryTreeNode
{
public:
    TYPE data;		  
    BinaryTreeNode *left;		
    BinaryTreeNode *right;	        
    BinaryTreeNode *parent;	       	                

    void release(BinaryTreeNode* _x);

    /** 
     * Default constructor. 
     * 
     */
    BinaryTreeNode(){};

	
    /** 
     * Constructor. Copy a node from the given const address.
     * 
     * @param _t The const address point to a node(can not be a
     * NULL).
     */
    BinaryTreeNode(const BinaryTreeNode *_t);

    /** 
     * Constructor. Copy a node from the given address.
     * 
     * @param _t The address point to a node(can not be a NULL).
     */
    BinaryTreeNode(BinaryTreeNode *_t);

    /** 
     * Constructor. Create a node with the data is the given
     * value _d.
     * 
     * @param _d Given value.
     */
    BinaryTreeNode(TYPE _d);

    /** 
     * Destructor.
     * 
     */
    ~BinaryTreeNode();
};

template <class TYPE>
BinaryTreeNode<TYPE>::BinaryTreeNode(const BinaryTreeNode *_t)
{
    if (_t == NULL)
    {
	std::cerr << "Error! Can not copy a NULL."<< std::endl;
	std::exit(-1);
    }
    data = _t->data;
    parent = left = right = NULL;
};

template <class TYPE>
BinaryTreeNode<TYPE>::BinaryTreeNode(BinaryTreeNode *_t)
{
    if (_t == NULL)
    {
	std::cerr << "Error! Can not copy a NULL."<< std::endl;
	std::exit(-1);
    }
    data = _t->data;
    parent = left = right = NULL;
};

template <class TYPE>
BinaryTreeNode<TYPE>::BinaryTreeNode(TYPE _d)
{
    data = _d;
    parent = left = right = NULL;
};

template <class TYPE>
BinaryTreeNode<TYPE>::~BinaryTreeNode()
{
    parent = left = right = NULL;
};
